package com.tw.trips.domain.fixture;

import java.util.Date;

import com.tw.trips.domain.Comment;
import com.tw.trips.domain.ItHelps;
import com.tw.trips.domain.Location;
import com.tw.trips.domain.Traveller;
import com.tw.trips.domain.Update;

public class UpdateFixture {
	private Update update;

	public UpdateFixture(Traveller updatedBy, Location forLocation,
			Date createdOn, String message, String imgURL, Comment comment,
			ItHelps itHelps) {
		update = new Update();
		update.setUpdatedBy(updatedBy);
		update.setForLocation(forLocation);
		update.setCreatedOn(createdOn);
		update.setMessage(message);
		update.setImgURL(imgURL);
		update.getComments().add(comment);
//		update.getItHelps().add(itHelps);
	}

	public Update create() {
		if (update == null)
			update = this.createUpdateForChennai();
		return update;
	}

	public UpdateFixture() {
		super();
	}

	private Update createUpdateForChennai() {
		Traveller traveller = new TravellerFixture("sripaul@mindtree.com",
				true, "Sripaul", "sripaul", null, null, null, null).create();
		UpdateFixture fixture = new UpdateFixture(traveller, null, new Date(),
				"Hi ! ", "image", null, null);
		return fixture.create();
	}

	public Update createForLocation(Location locn) {
		Traveller traveller = new TravellerFixture("sripaul@mindtree.com",
				true, "Sripaul", "sripaul", null, null, null, null).create();
		UpdateFixture fixture = new UpdateFixture(traveller, locn, new Date(),
				"Hi ! ", "image", null, null);
		Update update = fixture.create();
		update.setForLocation(locn);
		update.setUpdatedBy(traveller);
		ItHelps helps = new ItHelps(null, traveller, null);
//		update.getItHelps().add(helps);
		Comment comment = new Comment(new Date(), traveller, "Hi !");
		ItHelps commentHelps = new ItHelps(comment, traveller, null);
//		comment.getItHelps().add(commentHelps);
		update.getComments().add(comment);
		return update;
	}
}
